/*
package com.spirngcloud.alibabasentinelratelimiting.controller.redis;

import com.spirngcloud.alibabasentinelratelimiting.Func.Func;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.lang.Nullable;

import java.util.concurrent.Callable;

*/
/**
 * @version V1.0
 * @Author 宋聚智
 * @Date 2019/10/25 9:35
 * @description
 * @Modify By：
 * @ModifyTime： 2019/10/25
 * @Modify marker：
 **//*

    public class CacheUtil {
        private static CacheManager cacheManager = (CacheManager)SpringUtil.getBean(CacheManager.class);

        public CacheUtil() {
        }

        public static Cache getCache(String cacheName) {
            return cacheManager.getCache(cacheName);
        }

        @Nullable
        public static Object get(String cacheName, String keyPrefix, Object key) {
            return Func.hasEmpty(new Object[]{cacheName, keyPrefix, key}) ? null : getCache(cacheName).get(keyPrefix.concat(String.valueOf(key))).get();
        }

        @Nullable
        public static <T> T get(String cacheName, String keyPrefix, Object key, @Nullable Class<T> type) {
            return Func.hasEmpty(new Object[]{cacheName, keyPrefix, key}) ? null : getCache(cacheName).get(keyPrefix.concat(String.valueOf(key)), type);
        }

        @Nullable
        public static <T> T get(String cacheName, String keyPrefix, Object key, Callable<T> valueLoader) {
            if (Func.hasEmpty(new Object[]{cacheName, keyPrefix, key})) {
                return null;
            } else {
                try {
                    return getCache(cacheName).get(keyPrefix.concat(String.valueOf(key)), valueLoader);
                } catch (Exception var5) {
                    var5.printStackTrace();
                    return null;
                }
            }
        }

        public static void put(String cacheName, String keyPrefix, Object key, @Nullable Object value) {
            getCache(cacheName).put(keyPrefix.concat(String.valueOf(key)), value);
        }

        public static void evict(String cacheName, String keyPrefix, Object key) {
            if (!Func.hasEmpty(new Object[]{cacheName, keyPrefix, key})) {
                getCache(cacheName).evict(keyPrefix.concat(String.valueOf(key)));
            }
        }

        public static void clear(String cacheName) {
            if (!Func.isEmpty(cacheName)) {
                getCache(cacheName).clear();
            }
        }
    }

*/
